home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Think Class Libraries / SAT-TCL 1.0b2 / SAT-TCL ƒ / CSATPane.p < prev    next >
Encoding:
Text File  |  1996-06-08  |  4.8 KB  |  162 lines  |  [TEXT/PJMM]

  1. {****************************************************}
  2. {}
  3. {    CSATPane.p                                                                                                    }
  4. {}
  5. {    Panorama class for use with the Sprite Animation Toolkit. This basically        }
  6. {    calls SATCustomInit to set up the animation area, and implements it in a        }
  7. {    panorama.                                                                                                        }
  8. {}
  9. {    The bounds of the panorama are the rectangle specified to SAT. The other         }
  10. {    parameters are as per SAT. We ignore the options for centering the drawing    }
  11. {    area and filling the screen, since these are handled by the window class and     }
  12. {    the decorator class (if used).                                                                            }
  13. {}
  14. {    Important: Only one instance of this class should exist. This is where SAT        }
  15. {    thinks that its drawing area is.                                                                        }
  16. {}
  17. {****************************************************}
  18.  
  19.  
  20. unit CSATPane;
  21.  
  22. interface
  23.  
  24.     uses
  25.         TCL, SATTCLIntf;
  26.  
  27. implementation
  28.  
  29.  
  30. {****************************************************}
  31. {}
  32. {    ISATPane                                                                                                        }
  33. {}
  34. {    Initialize a SAT Pane class, and SAT. The drawing area for SAT specifies        }
  35. {    the bounds of the panorama.                                                                             }
  36. {}
  37. {****************************************************}
  38.  
  39.     procedure CSATPane.ISATPane (anEnclosure: CView;
  40.                                     aSupervisor: CBureaucrat;
  41.                                     aWidth, aHeight, aHEncl, aVEncl: Integer;
  42.                                     aHSizing, aVSizing: SizingOption;
  43.                                     aPICTColor, aPICTBW: Integer;
  44.                                     aSATRect: Rect;
  45.                                     aUseMenuBar, aDither4bit, aBeSmart: Boolean);
  46.  
  47.         var
  48.             theLongRect: LongRect;
  49.  
  50.     begin { ISATPane }
  51.         IPanorama(anEnclosure, aSupervisor, aWidth, aHeight, aHEncl, aVEncl, aHSizing, aVSizing);
  52.  
  53.         { Remember, a panorama pane is a window into the contents. }
  54.  
  55.         QDToLongRect(aSATRect, theLongRect);
  56.         OffsetLongRect(theLongRect, -theLongRect.left, -theLongRect.top);
  57.         SetBounds(theLongRect);
  58.  
  59.         SATCustomInit(aPICTColor, aPICTBW, aSATRect, WindowPtr(GetMacPort), nil, aUseMenuBar, FALSE, FALSE, aDither4bit, aBeSmart);
  60.     end; { ISATPane }
  61.  
  62.  
  63. {****************************************************}
  64. {}
  65. {    Draw                                                                                                            }
  66. {}
  67. {    TCL wants to draw the SAT pane. So draw it, as described in the manual.         }
  68. {    We don't use SATRedraw because we don't want the black bars.                        }
  69. {}
  70. {****************************************************}
  71.  
  72.     procedure CSATPane.Draw (var area: Rect);
  73.  
  74.     begin
  75.         { It may be worth putting in a call to SATDepthChangeTest here, if there is }
  76.         { a good way to use this information. }
  77.  
  78.         { Note that area is supplied in frame coordinates, and hence SAT coordinates. }
  79.  
  80.         CopyBits(gSAT.offScreen.port^.portbits, gSAT.wind.port^.portbits, area, area, srcCopy, nil);
  81.     end;
  82.  
  83.  
  84. {****************************************************}
  85. {}
  86. {    DoSATRun                                                                                                        }
  87. {}
  88. {    Call SATRun for one frame of animation, with the given fast parameter.            }
  89. {}
  90. {    SAT expects that its onscreen drawing area (the frame of the SAT Pane)        }
  91. {    is valid. However, we can't just call ValidRect with the frame, because            }
  92. {    there may be a updateEvt pending for the window.                                            }
  93. {}
  94. {    The cunning bit of subterfuge implemented here is to copy the update                }
  95. {    region of the window into a temporary region, validate the frame for                }
  96. {    SATRun, and then copy the region back so that the window's Update                }
  97. {    method can work as normal.                                                                            }
  98. {}
  99. {****************************************************}
  100.  
  101.     procedure CSATPane.DoSATRun (fast: Boolean);
  102.  
  103.         var
  104.             theQDRect: Rect;
  105.             theWindowPeek: WindowPeek;
  106.  
  107.     begin { DoSATRun }
  108.         theWindowPeek := WindowPeek(GetWindow.GetMacPort);
  109.  
  110.         CopyRgn(theWindowPeek^.updateRgn, gUtilRgn);
  111.  
  112.         FrameToQDR(frame, theQDRect);
  113.         ValidRect(theQDRect);
  114.  
  115.         SATRun(fast);
  116.  
  117.         CopyRgn(gUtilRgn, theWindowPeek^.updateRgn);
  118.  
  119.         SetEmptyRgn(gUtilRgn);
  120.     end; { DoSATRun }
  121.  
  122.  
  123. {****************************************************}
  124. {}
  125. {    DoSATRun2                                                                                                    }
  126. {}
  127. {    Call SATRun2 for one frame of animation, with the given fast parameter.        }
  128. {}
  129. {    SAT expects that its onscreen drawing area (the frame of the SAT Pane)        }
  130. {    is valid. However, we can't just call ValidRect with the frame, because            }
  131. {    there may be a updateEvt pending for the window.                                            }
  132. {}
  133. {    The cunning bit of subterfuge implemented here is to copy the update                }
  134. {    region of the window into a temporary region, validate the frame for                }
  135. {    SATRun, and then copy the region back so that the window's Update                }
  136. {    method can work as normal.                                                                            }
  137. {}
  138. {****************************************************}
  139.  
  140.     procedure CSATPane.DoSATRun2 (fast: Boolean);
  141.  
  142.         var
  143.             theQDRect: Rect;
  144.             theWindowPeek: WindowPeek;
  145.  
  146.     begin { DoSATRun }
  147.         theWindowPeek := WindowPeek(GetWindow.GetMacPort);
  148.  
  149.         CopyRgn(theWindowPeek^.updateRgn, gUtilRgn);
  150.  
  151.         FrameToQDR(frame, theQDRect);
  152.         ValidRect(theQDRect);
  153.  
  154.         SATRun2(fast);
  155.  
  156.         CopyRgn(gUtilRgn, theWindowPeek^.updateRgn);
  157.  
  158.         SetEmptyRgn(gUtilRgn);
  159.     end; { DoSATRun }
  160.  
  161.  
  162. end. { CSATPane }